﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;


namespace Model
{
   public class StudentDAO
    {
        public static DataTable GetData()
        {
            Class_Connection.addconnection();
            SqlCommand cmd = new SqlCommand("SELECT Mahv, HoDem, Ten, Ngaysinh ,Gioitinh, Diachi, Malop FROM Hocvien", Class_Connection.conn);
            SqlDataAdapter daStudent = new SqlDataAdapter(cmd);
            daStudent.SelectCommand = cmd;
            DataSet ds = new DataSet();
            daStudent.Fill(ds);
            return ds.Tables[0];
        }
        
        public static void updateData(DataTable dtStudent)
        {
            Class_Connection.addconnection();
            SqlCommand cmd = new SqlCommand("SELECT Mahv, HoDem, Ten, Ngaysinh ,Gioitinh, Diachi, Malop FROM Hocvien", Class_Connection.conn);
            SqlDataAdapter daStudent = new SqlDataAdapter(cmd);
            SqlCommandBuilder stu = new SqlCommandBuilder(daStudent);
            daStudent.Update(dtStudent);
            dtStudent.AcceptChanges();

        }
    }
}
